package com.wdy.service.impl;

import java.util.List;

import com.wdy.dao.RepairDao;
import com.wdy.po.Page;
import com.wdy.po.Repair;
import com.wdy.po.Result;
import com.wdy.po.Tenement;
import com.wdy.service.RepairManager;
import com.wdy.util.PageUtil;

public class RepairManagerImpl implements RepairManager {

	private RepairDao repairDao;
	
	public void setRepairDao(RepairDao repairDao) {
		this.repairDao = repairDao;
	}

	
	public void saveRepair(Repair Repair) {
		repairDao.save(Repair);
	}

	
	public void removeRepair(Repair Repair) {
		repairDao.delete(Repair);
	}

	
	public void updateRepair(Repair repair) {
		repairDao.attachDirty(repair);
	}

	
	public Repair getRepair(Integer id) {
		return repairDao.findById(id);
	}


	public List<Repair> listAll() {
		return repairDao.findAll();
	}

	
	public List<Repair> findByExample(Repair repair) {
		return repairDao.findByExample(repair);
	}


	public List<Repair> findByDate(String value) {
		return repairDao.findByDate(value);
	}


	public List<Tenement> findTenement(Object value) {
		return repairDao.findTenement(value);
	}
	
	
	public Result listRepair(Page page) {
		int totalRecords = this.repairDao.getRepairCount();
		page = PageUtil.createPage(page, totalRecords);
		List<Repair> users = (List<Repair>)this.repairDao.getRepairByPage(page);     
		return new Result(page, users);
	}

}
